/* 
Lexical analyzer for the C7 language
*/

%{
#include <string.h>
#include <stdio.h>
#include "program.tab.h"
%}

digit     [0-9]

%%
[ \t\n]    { }
"+"        { return yytext[0]; }
"-"        { return yytext[0]; }
"*"        { return yytext[0]; }
"/"        { return yytext[0]; }
"%"        { return yytext[0]; }
"("        { return yytext[0]; }
")"        { return yytext[0]; }
";"        { return yytext[0]; }
"="        { return ASSIGNOP; }
"<"        { return LT; }
">"        { return GT; }
"<="       { return LTE; }
">="       { return GTE;}
"=="       { return EQ;}
"!="       { return NEQ;}
"+="       { return PLUSEQ;}
"-="       { return MINUSEQ;}
"&&"       { return AND;}
"||"       { return OR;}
"if"       { return IF; }
"else"     { return ELSE; }
"fi"       { return FI; }
"while"    { return WHILE; }
"elihw"    { return ELIHW; }
"for"      { return FOR;}
"rof"      { return ROF;}
"int"      { return INTTYPE;}
"float"    { return FLOATTYPE;}
"fun"      { return FUN;}
"nuf"      { return NUF;}
"print"    { return PRINT;}
"return"   { return RETURN;}

[a-zA-Z_]([a-zA-Z0-9_]){0,255}    {yylval.ident = strdup(yytext);  return IDENT; }
("-")?{digit}+("."{digit}+)?          {yylval.value = atof(yytext); return NUMBER; }
.       {return yytext[0];}
%%
